package com.neusoft.util;

import java.util.Date;

public class StringDateUtil {
	public static String getStringDate(Date date) {
		//因为时间老大了，所以用long接
		long thatTimeSmtp = date.getTime();
		long nowTimeStme = new Date().getTime();
		
		String dateStr = null;
		long secondBetween = (nowTimeStme - thatTimeSmtp)/1000;
		if (secondBetween < 60) {
			dateStr = "刚刚"; 
		}else {
			long minuteBetween = secondBetween/60;
			if (minuteBetween < 60) {
				dateStr = minuteBetween + "分钟前";
			}else {
				long hourBetween = minuteBetween/60;
				if (hourBetween < 24) {
					dateStr = hourBetween + "小时前";
				}else {
					long dayBetween = hourBetween/24;
					if (dayBetween < 7) {
						dateStr = dayBetween + "天前";
					}else {
						dateStr = date.toLocaleString().split(" ")[0];
					}
				}
			}
			
		}
		return dateStr;
		
	}

}
